package com.swfgui.utils
{
	/**
	 * fullPath=dir+fileName+"."+extesion
	 * fullFileName=fileName+"."+extesion
	 * 注意，路径分隔符都用"/"，dir最后有个"/"
	 * @author llj
	 */
	public class FilePath
	{
		public var fullPath:String;
		public var dir:String="";
		public var fullFileName:String="";
		public var fileName:String="";
		public var extesion:String="";
		
		public static function getFilePath(path:String):FilePath
		{
			return new FilePath(path);
		}
		
		public function FilePath(path:String)
		{
			var newDir:String = path.replace(/\\/g, "/");
			fullPath = newDir;
			var last:int = newDir.lastIndexOf("/");
			if(last != -1)
			{
				dir = newDir.substring(0, last + 1);
				fullFileName = newDir.substr(last + 1);
			}
			else
			{
				dir = "./";
				fullFileName = newDir;
			}
			
			if(fullFileName != "")
			{
				var dot:int = fullFileName.lastIndexOf(".");
				if(dot != -1)
				{
					fileName = fullFileName.substring(0, dot);
					extesion = fullFileName.substring(dot + 1).toLowerCase();
				}
				else
				{
					fileName = fullFileName;
				}
			}
		}
		
		public static function isAbsolute(path:String):Boolean
		{
			return path.indexOf(":") != -1;
		}
	}
}